%%

/**
 * 
 * @author Bart Wentink & Sander Meijer
 *
 */
%class EBNFScanner
%implements EBNFTokenKinds
%function nextToken
%type Token

%unicode
%line
%column

%{
 
  /**
   * Utility methode om een token te maken.
   * @param kind token soort
   * @see TokenKinds
   */
  private Token createToken(int kind) {
    return new Token(kind,yyline+1,yycolumn+1,yytext());
  }

%}

LineTerminator	= \r|\n|\r\n
WhiteSpace		= {LineTerminator} | [ \t\f]
CONSTANT 		= \'.\'
IDENTIFIER		= [a-zA-Z0-9_-]+
ISDEFINEDAS		= :
EMPTY			= @
OR				= \|
EOR				= ;
EOBNF   		= \.
EOF				= #
LP              = \(
RP              = \)


%%

<YYINITIAL> {

{WhiteSpace}    {}
{CONSTANT}		{return createToken(CONSTANT);}
{IDENTIFIER}	{return createToken(IDENTIFIER);}
{ISDEFINEDAS}	{return createToken(ISDEFINEDAS);}
{EMPTY}			{return createToken(EMPTY);}
{OR}			{return createToken(OR);}
{EOR}			{return createToken(EOL);}
{EOBNF}			{return createToken(EOBNF);}
{EOF}			{return createToken(EOF);}
{LP}			{return createToken(LP);}
{RP}			{return createToken(RP);}



}

.|\n            {throw new RuntimeException(yytext()+" unmatched");}
